package com.ruoyi.common.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 系统优化配置
 * 
 * @author ruoyi
 * @date 2025-01-13
 */
@Component
@ConfigurationProperties(prefix = "optimization")
public class OptimizationConfig
{
    /** 库存缓存配置 */
    private StockConfig stock = new StockConfig();
    
    /** 异步处理配置 */
    private AsyncConfig async = new AsyncConfig();
    
    /** 分布式锁配置 */
    private LockConfig lock = new LockConfig();
    
    /**
     * 库存配置
     */
    public static class StockConfig
    {
        /** 是否启用库存缓存 */
        private boolean cacheEnabled = true;
        
        /** 库存缓存时间（秒） */
        private int cacheTtl = 3600;
        
        /** 同步到数据库间隔（秒） */
        private int syncInterval = 300;
        
        public boolean isCacheEnabled() {
            return cacheEnabled;
        }
        
        public void setCacheEnabled(boolean cacheEnabled) {
            this.cacheEnabled = cacheEnabled;
        }
        
        public int getCacheTtl() {
            return cacheTtl;
        }
        
        public void setCacheTtl(int cacheTtl) {
            this.cacheTtl = cacheTtl;
        }
        
        public int getSyncInterval() {
            return syncInterval;
        }
        
        public void setSyncInterval(int syncInterval) {
            this.syncInterval = syncInterval;
        }
    }
    
    /**
     * 异步配置
     */
    public static class AsyncConfig
    {
        /** 是否启用异步分佣 */
        private boolean commissionEnabled = true;
        
        /** 是否启用异步短信 */
        private boolean smsEnabled = true;
        
        public boolean isCommissionEnabled() {
            return commissionEnabled;
        }
        
        public void setCommissionEnabled(boolean commissionEnabled) {
            this.commissionEnabled = commissionEnabled;
        }
        
        public boolean isSmsEnabled() {
            return smsEnabled;
        }
        
        public void setSmsEnabled(boolean smsEnabled) {
            this.smsEnabled = smsEnabled;
        }
    }
    
    /**
     * 分布式锁配置
     */
    public static class LockConfig
    {
        /** 锁过期时间（秒） */
        private int expireTime = 10;
        
        public int getExpireTime() {
            return expireTime;
        }
        
        public void setExpireTime(int expireTime) {
            this.expireTime = expireTime;
        }
    }
    
    public StockConfig getStock() {
        return stock;
    }
    
    public void setStock(StockConfig stock) {
        this.stock = stock;
    }
    
    public AsyncConfig getAsync() {
        return async;
    }
    
    public void setAsync(AsyncConfig async) {
        this.async = async;
    }
    
    public LockConfig getLock() {
        return lock;
    }
    
    public void setLock(LockConfig lock) {
        this.lock = lock;
    }
}

